import type { CodeType, Patient, PatientList, User, UserInfo } from '@/types/user'
import { request } from '@/utils/request'

//密码登录
export const loginByPassword = (mobile: string, password: string) =>
  request<User>('login/password', 'post', { mobile, password })

//验证码登录
export const loginByMobile = (mobile: string, code: string) =>
  request<User>('/login', 'post', { mobile, code })

//获取短信验证码
export const sendMobileCode = (mobile: string, type: CodeType) =>
  request<{ code: string }>('/code', 'get', { mobile, type })

//获取个人信息
export const getUserInfo = () => request<UserInfo>('/patient/myUser')

// 获患者信息列表
export const getPatientList = () => request<PatientList>('/patient/mylist')

//添加患者
export const addPatient = (patient: Patient) => request('/patient/add', 'POST', patient)

//查询患者详情
export const getPatientDetails = (id: string) => request<Patient>(`/patient/info/${id}`)

//编辑患者信息
export const updatePatientInfo = (data: Patient) => {
  delete data.genderValue
  delete data.age
  return request<Patient>('/patient/update', 'PUT', data)
}
//删除患者信息
export const delPatientInfo = (id: string) => request<Patient>(`/patient/del/${id}`, 'DELETE')
